package com.wingsboat.factory.support;

import com.wingsboat.exception.BeanException;
import com.wingsboat.factory.config.BeanDefinition;

/**
 * @Author: wangzhong
 * @Date: 2023/11/19 11:00
 * @Description:
 **/

public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory {
    @Override
    protected Object creatBean(String beanName, BeanDefinition beanDefinition, Object[] args) throws BeanException {
        Object bean;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (IllegalAccessException | InstantiationException e) {
            throw new BeanException("创建bean失败");
        }
        addSingleton(beanName,bean);
        return bean;
    }
}
